
int STBY = 6;       /* STBY为正常工作/待机状态控制引脚 */

int AIN1 = 7;
int AIN2 = 8;
int PWMA = 10;

int BIN1 = 5;
int BIN2 = 4;
int PWMB = 9;

void setup()
{
  /* 设置引脚均为输出模式 */
  pinMode(STBY, OUTPUT);

  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);
  pinMode(PWMA, OUTPUT);

  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);
  pinMode(PWMB, OUTPUT);

  /* 设置 TB6112 为正常工作模式 */
  digitalWrite(STBY, HIGH);

  digitalWrite(AIN1, HIGH);
  digitalWrite(AIN2, LOW);

  digitalWrite(BIN1, HIGH);
  digitalWrite(BIN2, LOW);
}

void loop()
{
  int i = 0;

  for (i = 0; i < 256; i++)
  {
    analogWrite(PWMA, i);
    analogWrite(PWMB, i);
    delay(50);
  }
}
